package cn.wolfcode.p2p.business.service.impl;

import cn.wolfcode.p2p.business.domain.SystemAccount;
import cn.wolfcode.p2p.business.mapper.SystemAccountMapper;
import cn.wolfcode.p2p.business.service.ISystemAccountService;
import cn.wolfcode.p2p.util.Assert;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
@Slf4j
public class SystemAccountServiceImpl implements ISystemAccountService {

    @Autowired
    private SystemAccountMapper systemAccountMapper;

    @Override
    public SystemAccount getCurrent() {
        return systemAccountMapper.getCurrent();
    }

    @Override
    public void update(SystemAccount systemAccount) {

        log.error("系统账号修改信息失败,[乐观锁失败]");
        Assert.isFalse(0 == systemAccountMapper.updateByPrimaryKey(systemAccount),
                "系统账号修改信息失败,[乐观锁失败]");

    }
}
